package org.fireflow2.designer.eclipse.parts.tree;

import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editparts.AbstractTreeEditPart;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.fireflow.model.ModelElement;
import org.fireflow2.designer.eclipse.Activator;
import org.fireflow2.designer.eclipse.modelwrapper.ModelWrapper;
import org.fireflow2.designer.eclipse.modelwrapper.collection.RouterListWrapper;
import org.fireflow2.designer.eclipse.policies.NodeEditPolicy;

public class RouterTreePart extends AbstractTreeEditPart {
	private Image img = null;

	public RouterTreePart(){
		ImageDescriptor imageDescriptor = ImageDescriptor.createFromFile(Activator.class, "resources/router.png");
		img = imageDescriptor.createImage();
	}		
    protected void refreshVisuals() {
    	ModelWrapper wrapper = (ModelWrapper)this.getModel();
    	ModelElement elem = wrapper.getWorkflowModelElement();
    	this.setWidgetText((elem.getDisplayName()==null||elem.getDisplayName().equals(""))?elem.getName():elem.getDisplayName());
    	this.setWidgetImage(img);
    }	
	@Override
	protected void createEditPolicies() {
		// TODO Auto-generated method stub
      installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
	}     
}
